cmake_minimum_required(VERSION 2.8)

SET(DMPROJECT_NAME "dmgen4error")

PROJECT(${DMPROJECT_NAME})
INCLUDE(cmake/ModuleImport.cmake)
INCLUDE(cmake/ModuleCompileOptions.cmake)
ModuleSetCompileOptions()

SET(DMGEN_VERSION_MAJOR "1")
SET(DMGEN_VERSION_MINOR "0")
SET(DMGEN_VERSION_PATCH "1")
SET(DMGEN_VERSION "${DMGEN_VERSION_MAJOR}.${DMGEN_VERSION_MINOR}.${DMGEN_VERSION_PATCH}")

MESSAGE(STATUS "VERSION: ${DMGEN_VERSION}")

OPTION(USE_DMGEN4ERROR "use dmgen4error" ON)

ADD_DEFINITIONS(-DCTEMPLATE_DLL_DECL=)

ModuleImport("ctemplate" "thirdparty/ctemplate")
ExeImport("src" "ctemplate")

ADD_CUSTOM_COMMAND(
    TARGET ${DMPROJECT_NAME}
    PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/config/error/errorcode.xat
    $<TARGET_FILE_DIR:${DMPROJECT_NAME}>
)

ADD_CUSTOM_COMMAND(
    TARGET ${DMPROJECT_NAME}
    PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/config/error/builderror.sh
    $<TARGET_FILE_DIR:${DMPROJECT_NAME}>
)

ADD_CUSTOM_COMMAND(
    TARGET ${DMPROJECT_NAME}
    PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/config/error/builderror.bat
    $<TARGET_FILE_DIR:${DMPROJECT_NAME}>
)